import {Dimensions, Platform, PixelRatio} from 'react-native';
import {FontSize} from './font-size';

let {width, height} = Dimensions.get('window');
let pixelRatio = PixelRatio.get();
let screenPxW = PixelRatio.getPixelSizeForLayoutSize(width);
let basePx = Platform.OS === 'ios' ? 750 : 720;

// 像素转dp
const Px2Dp = function px2dp(px) {
  const scaleWidth = (px * screenPxW * 2) / basePx;
  return Math.round(scaleWidth / pixelRatio + 0.5);
};

export default {
  SCREEN_WIDTH: width,
  SCREEN_HEIGHT: height,
  iOS: Platform.OS === 'ios',
  Android: Platform.OS === 'android',
  Px2Dp,
  FontSize,
};
